class CulturalHeritage::Incidence < ActiveRecord::Base
 #default_scope where("cultural_heritage_incidences.deleted = 0")
  #has_many :list_avatars, :class_name => 'CulturalHeritage::IncidencesAvatar',  :foreign_key => 'incidence'
  #has_many :list_incidences, :class_name => 'CulturalHeritage::Incidence',  :foreign_key => 'foundInId'
  belongs_to :obj_cultural_heritage, :class_name => 'CulturalHeritage::CulturalHeritage', :foreign_key => 'culturalHeritage'
  belongs_to :obj_user, :class_name => 'User', :foreign_key => 'user'
  belongs_to :obj_person1, :class_name => 'Security::Person', :foreign_key => 'person1'
  belongs_to :obj_person2, :class_name => 'Security::Person', :foreign_key => 'person2'
  has_attached_file :avatar
  acts_as_gmappable :lat => 'latitude', :lng =>'longitude',:process_geocoding => :geocode?
#    class User < ActiveRecord::Base
#      has_attached_file :avatar
#    end
  def geocode?
    !(address.blank? || (!latitude.blank? && !longitude.blank?))
  end

  def gmaps4rails_address
  #describe how to retrieve the address from your model, if you use directly a db column, you can dry your code, see wiki
    "#{self.address}"
  end
  
  default_scope where("deleted = 0")

  

  def str_state
    if state == 0
      return "Registrado"
    end
    if state == 1
      return "Atendido"
    end
    if state == 2
      return "Rechazado"
    end
    if state == 3
      return "Asignado_INC"
    end
    if state == 4
      return "Asignado_Experto"
    end
    if state == 5
      return "Asignado_Experto_Ley"
    end
  end
end
